using System;
using System.IO;

namespace WowAceUpdater
{
    public sealed class TextWriterMessageWrapper : IDisposable
    {
        #region Fields

        private readonly string _endMessage;

        private readonly TextWriter _writer;

        #endregion

        #region Constructors

        public TextWriterMessageWrapper(string startMessage, string endMessage, TextWriter writer)
        {
            _writer = writer;
            _endMessage = endMessage;
            _writer.Write(startMessage);
        }

        public TextWriterMessageWrapper(string startMessage, TextWriter writer)
            : this(startMessage, " done.", writer)
        {
        }

        #endregion

        #region Public Methods

        public void Dispose()
        {
            _writer.WriteLine(_endMessage);
        }

        #endregion
    }
}